<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next-haha.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next-haha.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next-haha.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.0/css/all.min.css" integrity="sha256-VHqXKFhhMxcpubYf9xiWdCiojEbY9NexQ4jh8AxbvcM=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"ming.theyan.gs","root":"/","images":"/images","scheme":"Pisces","darkmode":false,"version":"8.25.0","exturl":false,"sidebar":{"position":"left","width_expanded":320,"width_dual_column":240,"display":"post","padding":18,"offset":12},"hljswrap":true,"codeblock":{"theme":{"light":"default","dark":"stackoverflow-dark"},"prism":{"light":"prism","dark":"prism-dark"},"copy_button":{"enable":false,"style":null},"fold":{"enable":false,"height":500},"language":false},"bookmark":{"enable":true,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"duration":200,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"top_n_per_article":1,"unescape":false,"preload":false,"trigger":"auto"}}</script><script src="/js/config.js" defer></script>

    <meta name="description" content="简述这是适合小型网络（公司办公室或家庭）的”科学上网”方案之一的ipv6方案，此方案是我极同事搞的，我这里主要是学习，然后做过在路由器上封来自于公网ipv6网往小型网络内部的机器（都有正式ipv6地址）的访问。 点评下：思路灰常灵活，非常适用于办公网、家庭网的“科学上网”方案 所用资源 路由器 极一（跑openwrt） ip地址（私网）：10.0.0.5 ip地址（公网）：3.3.3.3   虚机">
<meta property="og:type" content="article">
<meta property="og:title" content="小型网络科学上网方案之ipv6篇">
<meta property="og:url" content="https://ming.theyan.gs/2016/09/%E5%B0%8F%E5%9E%8B%E7%BD%91%E7%BB%9C%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91%E6%96%B9%E6%A1%88%E4%B9%8Bipv6%E7%AF%87/index.html">
<meta property="og:site_name" content="运维烂笔头">
<meta property="og:description" content="简述这是适合小型网络（公司办公室或家庭）的”科学上网”方案之一的ipv6方案，此方案是我极同事搞的，我这里主要是学习，然后做过在路由器上封来自于公网ipv6网往小型网络内部的机器（都有正式ipv6地址）的访问。 点评下：思路灰常灵活，非常适用于办公网、家庭网的“科学上网”方案 所用资源 路由器 极一（跑openwrt） ip地址（私网）：10.0.0.5 ip地址（公网）：3.3.3.3   虚机">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2016-09-29T03:37:21.000Z">
<meta property="article:modified_time" content="2019-04-04T23:47:07.029Z">
<meta property="article:author" content="老杨">
<meta property="article:tag" content="IPv6">
<meta property="article:tag" content="科学上网">
<meta property="article:tag" content="DNSCrypt">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://ming.theyan.gs/2016/09/%E5%B0%8F%E5%9E%8B%E7%BD%91%E7%BB%9C%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91%E6%96%B9%E6%A1%88%E4%B9%8Bipv6%E7%AF%87/">


<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://ming.theyan.gs/2016/09/%E5%B0%8F%E5%9E%8B%E7%BD%91%E7%BB%9C%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91%E6%96%B9%E6%A1%88%E4%B9%8Bipv6%E7%AF%87/index.html","path":"2016/09/小型网络科学上网方案之ipv6篇/index.html","title":"小型网络科学上网方案之ipv6篇"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>小型网络科学上网方案之ipv6篇 | 运维烂笔头</title>
  
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-106574959-2"></script>
  <script class="next-config" data-name="google_analytics" type="application/json">{"tracking_id":"UA-106574959-2","only_pageview":false,"measure_protocol_api_secret":null}</script>
  <script src="/js/third-party/analytics/google-analytics.js" defer></script>

  <script src="/js/third-party/analytics/baidu-analytics.js" defer></script>
  <script async src="https://hm.baidu.com/hm.js?fdef9ded31bdb8b2dab08eddebdd5fed"></script>







  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous" defer></script>
<script src="/js/utils.js" defer></script><script src="/js/motion.js" defer></script><script src="/js/sidebar.js" defer></script><script src="/js/next-boot.js" defer></script><script src="/js/bookmark.js" defer></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.5.0/search.js" integrity="sha256-xFC6PJ82SL9b3WkGjFavNiA9gm5z6UBxWPiu4CYjptg=" crossorigin="anonymous" defer></script>
<script src="/js/third-party/search/local-search.js" defer></script>







  




<!-- google adsense -->
<script data-ad-client="ca-pub-1045025618858716" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<link rel="alternate" href="/atom.xml" title="运维烂笔头" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">运维烂笔头</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">一个 SA 老兵的工作日志</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-projects"><a href="/projects" rel="section"><i class="fa fa-code fa-fw"></i>projects</a></li><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-sitemap"><a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a></li><li class="menu-item menu-item-commonweal"><a href="/404/" rel="section"><i class="fa fa-heartbeat fa-fw"></i>公益 404</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
      <div class="search-header">
        <span class="search-icon">
          <i class="fa fa-search"></i>
        </span>
        <div class="search-input-container">
          <input autocomplete="off" autocapitalize="off" maxlength="80"
                placeholder="搜索..." spellcheck="false"
                type="search" class="search-input">
        </div>
        <span class="popup-btn-close" role="button">
          <i class="fa fa-times-circle"></i>
        </span>
      </div>
      <div class="search-result-container">
        <div class="search-result-icon">
          <i class="fa fa-spinner fa-pulse fa-5x"></i>
        </div>
      </div>
    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%AE%80%E8%BF%B0"><span class="nav-number">1.</span> <span class="nav-text">简述</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%89%80%E7%94%A8%E8%B5%84%E6%BA%90"><span class="nav-number">1.1.</span> <span class="nav-text">所用资源</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%8E%9F%E7%90%86"><span class="nav-number">2.</span> <span class="nav-text">原理</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%AF%A6%E7%BB%86%E9%85%8D%E7%BD%AE"><span class="nav-number">3.</span> <span class="nav-text">详细配置</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%A2%E6%88%B7%E7%AB%AF"><span class="nav-number">3.1.</span> <span class="nav-text">客户端</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B7%AF%E7%94%B1%E5%99%A8"><span class="nav-number">3.2.</span> <span class="nav-text">路由器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%99%9A%E6%9C%BA"><span class="nav-number">3.3.</span> <span class="nav-text">虚机</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#DNSCrypt-proxy"><span class="nav-number">3.4.</span> <span class="nav-text">DNSCrypt-proxy</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HE"><span class="nav-number">3.5.</span> <span class="nav-text">HE</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="nav-number">4.</span> <span class="nav-text">参考资料</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">老杨</p>
  <div class="site-description" itemprop="description">好记性比不过烂笔头</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">114</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">509</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/haw-haw" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;haw-haw" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:blog@theyan.gs" title="E-Mail → mailto:blog@theyan.gs" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/u/1494877243" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;u&#x2F;1494877243" rel="noopener me" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://twitter.com/6fool" title="Twitter → https:&#x2F;&#x2F;twitter.com&#x2F;6fool" rel="noopener me" target="_blank"><i class="fab fa-twitter fa-fw"></i>Twitter</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
    <div class="sidebar-inner sidebar-blogroll">
      <div class="links-of-blogroll animated">
        <div class="links-of-blogroll-title"><i class="fa fa-globe fa-fw"></i>
          链接
        </div>
        <ul class="links-of-blogroll-list">
            <li class="links-of-blogroll-item">
              <a href="https://bad-pencil.github.io/" title="https:&#x2F;&#x2F;bad-pencil.github.io" rel="noopener" target="_blank">github 镜像站</a>
            </li>
            <li class="links-of-blogroll-item">
              <a href="https://hawhaw.gitee.io/" title="https:&#x2F;&#x2F;hawhaw.gitee.io" rel="noopener" target="_blank">gitee 镜像站</a>
            </li>
        </ul>
      </div>
    </div>
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://ming.theyan.gs/2016/09/%E5%B0%8F%E5%9E%8B%E7%BD%91%E7%BB%9C%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91%E6%96%B9%E6%A1%88%E4%B9%8Bipv6%E7%AF%87/index.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="老杨">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="运维烂笔头">
      <meta itemprop="description" content="好记性比不过烂笔头">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="小型网络科学上网方案之ipv6篇 | 运维烂笔头">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          小型网络科学上网方案之ipv6篇
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2016-09-29 11:37:21" itemprop="dateCreated datePublished" datetime="2016-09-29T11:37:21+08:00">2016-09-29</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2019-04-05 07:47:07" itemprop="dateModified" datetime="2019-04-05T07:47:07+08:00">2019-04-05</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><h1 id="简述"><a href="#简述" class="headerlink" title="简述"></a>简述</h1><p>这是适合小型网络（公司办公室或家庭）的”科学上网”方案之一的ipv6方案，此方案是我极同事搞的，我这里主要是学习，然后做过在路由器上封来自于公网ipv6网往小型网络内部的机器（都有正式ipv6地址）的访问。</p>
<p>点评下：<br>思路灰常灵活，非常适用于办公网、家庭网的“科学上网”方案</p>
<h2 id="所用资源"><a href="#所用资源" class="headerlink" title="所用资源"></a>所用资源</h2><ol>
<li>路由器<ul>
<li>极一（跑openwrt）</li>
<li>ip地址（私网）：10.0.0.5</li>
<li>ip地址（公网）：3.3.3.3</li>
</ul>
</li>
<li>虚机<ul>
<li>IPV6</li>
<li>2.2.2.2</li>
<li>dnscrypt-wrapper(optional)<ul>
<li>用来配合 dnscrypt-proxy 直连，破除 dns 污染</li>
</ul>
</li>
</ul>
</li>
<li>DNSCrypt-proxy(optional)<ul>
<li>解决某些域名被 dns 污染的问题。</li>
</ul>
</li>
<li>HE的账号</li>
</ol>
<a id="more"></a>
<table border="1" cellpadding="1" cellspacing="0"><tbody><tr><td>地址</td><td><a href="https://www.tunnelbroker.net/" target="_blank" rel="noopener">https://www.tunnelbroker.net/</a></td></tr><tr><td>账号</td><td>xxxxxx</td></tr><tr><td>email</td><td><a href="mailto:admin@xxxxxx.xx" target="_blank" rel="noopener">admin@xxxxxx.xx</a></td></tr><tr><td>prefix</td><td>2001:xxx:xxxx::/48</td></tr><tr><td>server’s ipv4 address</td><td>1.1.1.1</td></tr><tr><td>server’s ipv6 address</td><td>2001:xxx:xx:xxx::1/64</td></tr><tr><td>client’s ipv4 address</td><td>2.2.2.2</td></tr><tr><td>client’s ipv6 address</td><td>2001:xxx:xx:xxx::2/64</td></tr></tbody></table>

<h1 id="原理"><a href="#原理" class="headerlink" title="原理"></a>原理</h1><ul>
<li>通过虚机(我司在oneasiahost买的，ip:2.2.2.2)从HE(HURRICANE ELECTRIC INTERNET SERVICES)的IPv6 Tunnel Broker上申请一段免费的ipv6地址（/48的）</li>
<li>然后通过小型网络内的路由器(ip是3.3.3.3)分配给局域网的客户端</li>
<li>路由器通过sit tunnel打到虚机2.2.2.2上</li>
<li>虚机2.2.2.2上起iptables，将sit过来的包(来自3.3.3.3)都转给HE（ip这里是：1.1.1.1）</li>
</ul>
<h1 id="详细配置"><a href="#详细配置" class="headerlink" title="详细配置"></a>详细配置</h1><h2 id="客户端"><a href="#客户端" class="headerlink" title="客户端"></a>客户端</h2><p>简单说，客户端只要接入此小型网络，并在本地启用了ipv6协议即可。</p>
<h2 id="路由器"><a href="#路由器" class="headerlink" title="路由器"></a>路由器</h2><ul>
<li><p>sit tunnel(文件/etc/config/network里)</p>
<figure class="highlight apache"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">config</span> interface 'sit1'</span><br><span class="line">        <span class="attribute">option</span> proto '6in4'</span><br><span class="line">        <span class="attribute">option</span> peeraddr '2.2.2.2'</span><br><span class="line">        <span class="attribute">option</span> ip6addr '2001:xxx:xx:xxx::2/64'</span><br><span class="line">        <span class="attribute">option</span> ip6prefix '2001:xxx:xxxx::/48'</span><br><span class="line"><span class="comment">#        option defaultroute '1'</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>iptables</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 允许sit1对端的机器的包出入路由器</span></span><br><span class="line">iptables -A INPUT -s 2.2.2.2/32 -i 6in4-sit1 -p ipv6 -j ACCEPT</span><br><span class="line">iptables -A OUTPUT -d 2.2.2.2/32 -o 6in4-sit1 -p ipv6 -j ACCEPT</span><br></pre></td></tr></table></figure>
</li>
<li><p>ip6tables</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">ip6tables -A INPUT -i 6in4-sit1 -m state --state RELATED,ESTABLISHED -j ACCEPT</span><br><span class="line">ip6tables -A INPUT -i 6in4-sit1 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j DROP</span><br><span class="line">ip6tables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT</span><br><span class="line">ip6tables -A INPUT -p ipv6-icmp -m icmp6 --icmpv6-type 128 -m <span class="built_in">limit</span> --<span class="built_in">limit</span> 30/min -j ACCEPT</span><br><span class="line">ip6tables -A FORWARD -i 6in4-sit1 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j DROP</span><br><span class="line">ip6tables -A OUTPUT -o 6in4-sit1 -p ipv6-icmp -j ACCEPT</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="虚机"><a href="#虚机" class="headerlink" title="虚机"></a>虚机</h2><p>iptables中的NAT表中</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">iptables -A PREROUTING -s 3.3.3.3/29 -p ipv6 -j DNAT --to-destination 1.1.1.1</span><br></pre></td></tr></table></figure>
<p>起 dnscrypt-wrapper：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">yum -y install libsodium libevent;</span><br><span class="line"><span class="comment"># 准备软件环境</span></span><br><span class="line"><span class="built_in">cd</span> /root;</span><br><span class="line">git <span class="built_in">clone</span> --recursive git://github.com/cofyc/dnscrypt-wrapper.git;</span><br><span class="line"><span class="built_in">cd</span> dnscrypt-wrapper;</span><br><span class="line">make configure;</span><br><span class="line">./configure;</span><br><span class="line">make install;</span><br><span class="line"><span class="comment"># 安装 dnscrypt-wrapper</span></span><br><span class="line">dnscrypt-wrapper --gen-provider-keypair;</span><br><span class="line">dnscrypt-wrapper --gen-crypt-keypair --crypt-secretkey-file=1.key;</span><br><span class="line">dnscrypt-wrapper --gen-cert-file \</span><br><span class="line">  --crypt-secretkey-file=1.key \</span><br><span class="line">  --provider-cert-file=1.cert \</span><br><span class="line">  --provider-publickey-file=public.key \</span><br><span class="line">  --provider-secretkey-file=secret.key \</span><br><span class="line">  --cert-file-expire-days=3650;</span><br><span class="line">dnscrypt-wrapper --resolver-address=8.8.8.8:53 \</span><br><span class="line">  --listen-address=0.0.0.0:443 \</span><br><span class="line">  --provider-name=2.dnscrypt-cert.xxxxxxxx.com \</span><br><span class="line">  --crypt-secretkey-file=1.key \</span><br><span class="line">  --provider-cert-file=1.cert \</span><br><span class="line">  -d;</span><br><span class="line"><span class="comment"># "xxxxxxxx.com" 是随意写的，只要整个名字跟别的不重即可</span></span><br><span class="line">dnscrypt-wrapper --show-provider-publickey-fingerprint \</span><br><span class="line">  --provider-publickey-file public.key;</span><br><span class="line"><span class="comment"># 返回的 Provider public key fingerprint 记下来，跑 dnscrypt-proxy 时要用</span></span><br></pre></td></tr></table></figure>
<h2 id="DNSCrypt-proxy"><a href="#DNSCrypt-proxy" class="headerlink" title="DNSCrypt-proxy"></a>DNSCrypt-proxy</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">wget --no-check-certificate https://download.dnscrypt.org/dnscrypt-proxy/old/dnscrypt-proxy-1.4.0.tar.bz2;</span><br><span class="line">tar xjvf dnscrypt-proxy-1.4.0.tar.bz2;</span><br><span class="line"><span class="built_in">cd</span> dnscrypt-proxy-1.4.0;</span><br><span class="line">./configure --prefix=/opt/dnscrypt;</span><br><span class="line">make;</span><br><span class="line">make install;</span><br><span class="line"><span class="built_in">cd</span> /opt/dnscrypt/sbin;</span><br><span class="line">./dnscrypt-proxy --<span class="built_in">local</span>-address=10.0.0.7:53 \</span><br><span class="line">  --resolver-address=2.2.2.2:443 \</span><br><span class="line">  --provider-name=2.dnscrypt-cert.xxxxxxxx.com \</span><br><span class="line">  --provider-key= \</span><br><span class="line">B735:1140:206F:225D:3E2B:D822:D7FD:691E:A1C3:3CC8:D666:8D0C:BE04:BFAB:CA43:FB79 \</span><br><span class="line">  -d;</span><br><span class="line"></span><br><span class="line"><span class="comment"># "xxxxxxxx.com" 要跟前面的对应</span></span><br><span class="line"><span class="comment"># “B735:1140:206F:225D:3E2B:D822:D7FD:691E:A1C3:3CC8:D666:8D0C:BE04:BFAB:CA43:FB79”</span></span><br><span class="line"><span class="comment"># 是前面取的的 Provider public key fingerprint</span></span><br></pre></td></tr></table></figure>
<p>这里的10.0.0.7是私网的一台机器，在私网的dns服务器上可以把被污染了的域名的dns解析请求forward到10.0.0.7的53端口上来即可解决dns污染问题。</p>
<h2 id="HE"><a href="#HE" class="headerlink" title="HE"></a>HE</h2><p>HE无需专门配置。</p>
<h1 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h1><ul>
<li><a href="https://github.com/Cofyc/dnscrypt-wrapper" target="_blank" rel="noopener">dnscrypt-wrapper@github</a></li>
<li><a href="https://github.com/jedisct1/dnscrypt-proxy" target="_blank" rel="noopener">dnscrypt-proxy@github</a></li>
<li><a href="https://dnscrypt.org/" target="_blank" rel="noopener">DNSCrypt</a></li>
</ul>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="reward-container">
  <div>请我一杯咖啡吧！</div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wechat-reward.png" alt="老杨 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="/images/alipay-reward.png" alt="老杨 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          <div class="followme">
  <span>欢迎关注我的其它发布渠道</span>

  <div class="social-list">

      <div class="social-item">
          <a target="_blank" class="social-link" href="https://twitter.com/6fool">
            <span class="icon">
              <i class="fab fa-twitter"></i>
            </span>

            <span class="label">Twitter</span>
          </a>
      </div>

      <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
      </div>
  </div>
</div>

          <div class="post-tags">
              <a href="/tags/IPv6/" rel="tag"># IPv6</a>
              <a href="/tags/%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91/" rel="tag"># 科学上网</a>
              <a href="/tags/DNSCrypt/" rel="tag"># DNSCrypt</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2016/09/%E6%80%8E%E6%A0%B7%E9%80%9A%E8%BF%87%E7%BD%91%E7%BB%9C%E5%9C%A8%E4%B8%A4%E5%8F%B0Linux%E4%B9%8B%E9%97%B4%E5%80%92%E6%95%B0%E6%8D%AE/index.html" rel="prev" title="怎样通过网络在两台Linux之间倒数据">
                  <i class="fa fa-angle-left"></i> 怎样通过网络在两台Linux之间倒数据
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2016/10/Linux%E4%B8%8B%E7%94%A8%E6%88%B7%E5%90%AF%E7%94%A8Windows-AD%E5%81%9A%E9%9B%86%E4%B8%AD%E8%AE%A4%E8%AF%81/index.html" rel="next" title="Linux下用户启用Windows AD做集中认证">
                  Linux下用户启用Windows AD做集中认证 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">老杨</span>
  </div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>

</body>
</html>
